// src/App.tsx
import { BrowserRouter as Router, Route, Routes, Link, Navigate } from 'react-router-dom';
import SnippetList from './SnippetList';
import SnippetDetail from './SnippetDetail';
import SnippetForm from './SnippetForm';

function App() {
  return (
    <Router>
      <div className="container">
        <nav>
          <Link to="/snippets" className="nav-link">代码列表</Link>
          <Link to="/snippets/create" className="nav-link">新建代码</Link>
        </nav>

        <Routes>
          <Route path="/" element={<Navigate to="/snippets" replace />} />
          <Route path="/snippets" element={<SnippetList />} />
          <Route path="/snippets/create" element={<SnippetForm />} />
          <Route path="/snippets/:id" element={<SnippetDetail />} />
          <Route path="/snippets/edit/:id" element={<SnippetForm />} />
        </Routes>
      </div>
    </Router>
  );
}

export default App;